class PublicController < ApplicationController
   caches_page :webcomic, :index, :bookmark
  
  def index
    @comic = Comic.most_recent_page
	render :template => 'public/webcomic'
  end
  
  def webcomic
    @comic = Comic.find(params[:id])
	rescue
	  @comic = Comic.most_recent_page
  end
  
  def bookmark
    if params[:v]
	  @comic = Comic.find(:first, :conditions=>['volume_id = ?',params[:v]], :order=>'rank asc')
	elsif params[:c] && params[:s]
	  @comic = Comic.find(:first, :conditions=>['story_id= ? and chapter_id = ?',params[:s],params[:c]], :order=>'rank asc')	  
	elsif params[:s]
	  @comic = Comic.find(:first, :conditions=>['story_id = ?',params[:s]], :order=>'rank asc')
	end
	if !@comic
	  index and return
	end
	render :template => 'public/webcomic'
  end
  

end
